#include "StompedReality/Components/AABBComponent.h"
#include "StompedReality/Core/ComponentConstuctionHelper.h"
#include "StompedReality/Core/Graphics/BasicRenderFunctions.h"
#include "StompedReality/Core/TypeSystem/TypeSystem.h"
#include <assert.h>

CreateRegDummy( AABBComponent )

namespace StompedReality
{
namespace components
{

AABBComponent::AABBComponent( )
{
}

AABBComponent::~AABBComponent( )
{
}

void AABBComponent::Draw( )
{

}

void AABBComponent::OnCreation( )
{
  Component::OnCreation( );
  this->m_HalfSize = StompedReality::Math::Vector2 ( 0, 0 );
}

void AABBComponent::OnDestruction( )
{
  Component::OnDestruction( );
}

void AABBComponent::InitializeComponent( StompedReality::Core::ComponentConstuctionHelper* constructionHelper )
{
  this->m_TranslationDelegate = constructionHelper->CreateGetterDelegateDeref<StompedReality::Math::Vector2>(
      "linked", "translation" );

  StompedReality::Graphics::Functions::RenderRectangle* aabb = new StompedReality::Graphics::Functions::RenderRectangle (
      250 );
  aabb->HalfSize = this->m_HalfSize;
  aabb->Center = this->m_TranslationDelegate( );

  constructionHelper->AddRenderFunction( aabb );
}

bool AABBComponent::ProcessMessage ( StompedReality::Core::Message* msg )
{
  return true;
}

void AABBComponent::Update ( )
{
}

StompedReality::Math::Vector2 AABBComponent::getHalfSize( )
{
  return this->m_HalfSize;
}

void AABBComponent::SetHalfSize ( StompedReality::Math::Vector2 halfSize )
{
  this->m_HalfSize = halfSize;
}

int AABBComponentReg::registeType( )
{
  return ( int ) ( StompedReality::type_system::TypeSystem::CreateTypeInfo<AABBComponent> ( "AABBComponent" )->
                   addTypeField ( StompedReality::type_system::TypeField ( "halfSize",
                                                                           &AABBComponent::m_HalfSize ) ) );
}

static int typeReg = AABBComponentReg::registeType( );
}
}
